package com.znsd.stu.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.znsd.entitys.ClassInfo;
import com.znsd.entitys.NoticeInfo;
import com.znsd.entitys.Users;
import com.znsd.stu.dao.NoticeDao;
import com.znsd.stu.service.NoticeService;
@Service
public class NoticeServiceImpl implements NoticeService {
	@Autowired
	private NoticeDao noticeDao;

	@Override
	public List<NoticeInfo> queryNoticeAll(Integer page, Integer limit) {
		return noticeDao.selectNoticeAll(page,limit);
	}

	@Override
	public Integer queryNoticeCount() {
		return noticeDao.selectNoticeCount();
	}

	@Override
	public Integer addNotice(Users user,NoticeInfo notice, Integer clazz) {
		notice.setTeacher_id(user);
		Date date=new Date();
		notice.setCreatetime(date);
		ClassInfo classInfo=new ClassInfo();
		classInfo.setClazz_id(clazz);
		notice.setClazz_id(classInfo);
		return noticeDao.addNotice(notice);
	}

	@Override
	public Integer delNotice(int parseInt) {
		NoticeInfo notice=new NoticeInfo();
		notice.setNotice_id(parseInt);
		notice.setDeltime(new Date());
		return noticeDao.delNotice(notice);
	}

	@Override
	public Integer updateNotice( NoticeInfo notice, Integer clazz) {
		Date date=new Date();
		notice.setUpdatetime(date);
		ClassInfo classInfo=new ClassInfo();
		classInfo.setClazz_id(clazz);
		notice.setClazz_id(classInfo);
		return noticeDao.updateNotice(notice);
	}

	
}
